package com.springSecurity.demo;

import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * 自定义密码验证
 */
public class MyPasswordEncode implements PasswordEncoder{
    private final static String SALT = "123456";
    @Override
    public String encode(CharSequence password) {
        Md5PasswordEncoder encoder = new Md5PasswordEncoder();

        return encoder.encodePassword(password.toString(),SALT);
    }

    @Override
    public boolean matches(CharSequence password, String strPassword) {
        Md5PasswordEncoder encoder = new Md5PasswordEncoder();

        return encoder.isPasswordValid(strPassword,password.toString(),SALT);
    }
}
